package outer;

import java.util.ArrayList;

/**
 * java通过内部类+接口，可以很好的实现多继承的效果。
 */
public class Outer {

    private String name;

    //内部类
    public final class Inner {
        private String name;

        public void t1() {
            Outer.this.name = "1";  //访问外部
        }
    }

    public Inner newInner() {
        return new Inner();
    }


    //静态内部类
    public static class Note {
        private String name;

    }

    //局部内部类
    public ArrayList getContext() {
        class NoteNote extends ArrayList<String> {
        }
        return new NoteNote();
    }

    //匿名内部类
    public Runnable getRunnable() {
        return () -> System.out.println(111);
    }


    public static void main(String[] args) {
        Outer outer = new Outer();

        Outer.Inner inner1 = outer.new Inner();
        Outer.Inner inner2 = outer.newInner();

        Outer.Note note = new Outer.Note();

        outer.getContext();
        outer.getRunnable();

    }
}
